//
//  Macros.h
//  Takeaway
//
//  Created by chen on 2018/3/19.
//  Copyright © 2018年 LZQ. All rights reserved.
//

#ifndef Macros_h
#define Macros_h

#define MoneyCode @"P"

#define WEAK(weakSelf,self)  __weak __typeof(&*self)weakSelf = self;

#define IS_IPAD    (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define KIsiPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

// 顶部安全区域远离高度
#define kTopBarSafeHeight (KIsiPhoneX? 44 : 0)
// 底部安全区域远离高度
#define kBottomSafeHeight (KIsiPhoneX ? 34 : 0)
// 状态栏和导航栏总高度
#define kNavigationBarHeight  (KIsiPhoneX ? 88 : 64)
/**  TabBar高度 */
#define kTabBarHeight         (KIsiPhoneX ? 83.0 : 49.0)

#define Botoom_IPhoneX        (KIsiPhoneX?34.0f:0.0f)
// 分割线高度
#define kLineHeight (1.0/SCREENSCALE)
#define kTableViewHeight SCREENHEIGHT-kNavigationBarHeight

#define SCREEN_SCALE    [UIScreen mainScreen].scale
#define SCREEN_WIDTH    [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT   [UIScreen mainScreen].bounds.size.height
#define SCREENSCALE [UIScreen mainScreen].scale
#define SCREENWIDTH [UIScreen mainScreen].bounds.size.width
#define SCREENHEIGHT [UIScreen mainScreen].bounds.size.height

#define TOPOFFSET(y)    (KIsiPhoneX ? y+44 : y+20)
#define BOTTOMOFFSET(y) (KIsiPhoneX ? y-34 : y)

#define MaxX(view)      CGRectGetMaxX(view.frame)
#define MaxY(view)      CGRectGetMaxY(view.frame)
#define MidX(view)      CGRectGetMidX(view.frame)
#define MidY(view)      CGRectGetMidY(view.frame)
#define MinX(view)      CGRectGetMinX(view.frame)
#define MinY(view)      CGRectGetMinY(view.frame)
#define Width(view)     CGRectGetWidth(view.frame)
#define Height(view)    CGRectGetHeight(view.frame)


#define X(x) ([UIDevice isPhoneXorPad] ? x : (SCREENWIDTH / 375.0 * x))
#define Y(y) TY(y)
#define TY(y) ([UIDevice isPhoneXorPad] ? y : ((SCREENHEIGHT - 64) / (667.0 - 64) * y))

// 国际化宏定义
//#define LocalString(string) [LanguageHelper getString:string]

#define HEXCOLOR(hex)   [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16)) / 255.0 green:((float)((hex & 0xFF00) >> 8)) / 255.0 blue:((float)(hex & 0xFF)) / 255.0 alpha:1]

#define StringFromInt(x) [NSString stringWithFormat:@"%d",x]
#define StringFromLongInt(x) [NSString stringWithFormat:@"%ld",x]

#define YQImg(a) [UIImage imageNamed:a]
#define YQFont(x) [UIFont systemFontOfSize:x]
#define UserdefaultsIdtifier @"selectedTabbarIndex"
#define YQ_UserDefaults       [NSUserDefaults standardUserDefaults]
//*****************push*******************//
#define YQ_PUSH(vc) [self.navigationController pushViewController:vc animated:YES]
#define push_push(UIViewController) UIViewController *ctl = [[UIViewController alloc] init];\
[ctl setHidesBottomBarWhenPushed:YES];\
[self.navigationController pushViewController:ctl animated:YES]\
//*****************push*******************//
#define scrnW [UIScreen mainScreen].bounds.size.width
#define scrnH [UIScreen mainScreen].bounds.size.height
#define BackgroudColor HEXCOLOR(0xeeeeee)
#define smallFont YQFont(15)
#define NarmalColor [UIColor whiteColor]
#define YQ_POP [self.navigationController popViewControllerAnimated:YES]
#define isLogin @"isLogin"
#define YQ_UserDefaults       [NSUserDefaults standardUserDefaults]
#define CellNormalFont [UIFont systemFontOfSize:16]


#define YQ_Nor_img @"nor_icon_game"
#define YQ_Sel_img @"sel_icon_game"
#define YQ_Button_SetImg_nor(btn,imgName) [btn setImage:YQImg(imgName) forState:UIControlStateNormal]
#define YQ_Button_SetImg_sel(btn,imgName) [btn setImage:YQImg(imgName) forState:UIControlStateSelected]

//添加队员的表
#define YQ_AddPlayTableName @"YQAddPlay.sqlite"

#pragma mark - color
#pragma mark 分割线
#define COLOR_Line_Blue UIColorFromRGB(0x0078dd)//
#define COLOR_Line_Big_Gay UIColorFromRGB(0xcfcfcf)//
#define COLOR_Line_Small_Gay UIColorFromRGB(0xe5e5e5) //栏目分割线颜色
#define COLOR_Line_Red  UIColorFromRGB(0xfd4e3d)
#define COLOR_Line_E5_Gray UIColorFromRGB(0xe5e5e5)
#define COLOR_Line_E6_Gray UIColorFromRGB(0xe6e6e6)
#pragma mark 文字用色

#define COLOR_Text_939393 UIColorFromRGB(0x939393)
#define COLOR_Text_898989 UIColorFromRGB(0x898989)
#define COLOR_TEXT_BC UIColorFromRGB(0xbcbcbc)
#define COLOR_Text_Content UIColorFromRGB(0x333333)
#define COLOR_Text_gold UIColorFromRGB(0xa27428)
#define COLOR_Text_Blue UIColorFromRGB(0x507daf)
#define COLOR_Text_E6_Disable UIColorFromRGB(0xe6e6e6)
#define COLOR_Text_BC_Disable UIColorFromRGB(0xbcbcbc)
#define COLOR_Text_Red  UIColorFromRGB(0xfd4e3d)
#define COLOR_Text_Gay UIColorFromRGB(0x919191)//文字灰色
#define COLOR_Text_Black UIColorFromRGB(0x4c4c4c)//文字黑色
#define COLOR_Text_343434 UIColorFromRGB(0x343434)//
#define COLOR_Text_E5E5E5 UIColorFromRGB(0xe5e5e5)//
#define COLOR_Text_038CFF UIColorFromRGB(0x038cff)//
#define COLOR_Text_0078DD UIColorFromRGB(0x0078dd)//
#define COLOR_Text_B2B2B2 UIColorFromRGB(0xb2b2b2)//
#define COLOR_Text_BigBlack UIColorFromRGB(0x000000)//纯黑色

#define NavBarColor                             UIColorFromRGB(0x192238)//背景暗黑
#define WhiteColor                              UIColorFromRGB(0xffffff)//白色
#define MainThemeBlueColor                      UIColorFromRGB(0xDDB266)//背景暗蓝
#define MainThemeColor                          UIColorFromRGB(0xDDB266)//主题蓝
#define MainThemeLightColor                     UIColorFromRGB(0xF4CB82)//主页亮蓝色
#define MainThemeHighlightColor                 UIColorFromRGBWithAlpha(0xF4CB82,0.9)//主题高亮蓝
#define MainBlackColor                          UIColorFromRGB(0x232629)//主题标签黑色



#define LineColor                               UIColorFromRGB(0xd1d6e2)//分割线颜色
#define MainLabelLightBlackColor                UIColorFromRGB(0x656566)//label黑色
#define MainLabelBlackColor                     UIColorFromRGB(0x232629)//label黑色
#define MainLabelGrayColor                      UIColorFromRGB(0x747E8C)//label灰色
#define MainViewBorderColor                     UIColorFromRGBWithAlpha(0x192238, 0.15)//view 边框色
#define MainBackgroundColor                     UIColorFromRGB(0xFFFFFF)//背景灰色
#define MainBackgroundGrayColor                 UIColorFromRGB(0xF0F2F5)//背景灰色


#define MainBuyButtonBackgroundColor            UIColorFromRGB(0x03C087)//买入绿色
#define MainSellButtonBackgroundColor           UIColorFromRGB(0xFF6333)//卖出红色
#define MainNavBarColor                         UIColorFromRGB(0xffffff)//导航栏白色
#define MainC2CBackgroundColor                  UIColorFromRGB(0xf7f8fa)//背景灰色
#define MainC2CBlueColor                        UIColorFromRGB(0x6188EA)//C2C相关功能蓝色


#define color_333333 UIColorFromRGB(0x333333)
#define color_ffbd5b UIColorFromRGB(0xffbd5b)
#define color_f2f2f2 UIColorFromRGB(0xf2f2f2)
#define color_d2d2d2 UIColorFromRGB(0xd2d2d2)
#define color_ffdead UIColorFromRGB(0xffdead)


#pragma mark 背景用色
#define COLOR_Bg_White UIColorFromRGB(0xffffff)//
#define COLOR_Bg_Gay UIColorFromRGB(0xf8f8f8)//
#define COLOR_Bg_Blue UIColorFromRGB(0x0078dd)//
#define COLOR_Bg_Red UIColorFromRGB(0xf6594e)//
#define COLOR_Bg_Green UIColorFromRGB(0x0fc167)//
#define COLOR_Bg_Black UIColorFromRGB(0x000000)//
#define COLOR_Bg_FEA69E_Disable   UIColorFromRGB(0xfea69e)
#define COLOR_Bg_F9_Disable     UIColorFromRGB(0xf9f9f9)
#define COLOR_BG_Red  UIColorFromRGB(0xfd4e3d)
#define COLOR_BG_F2_Gray UIColorFromRGB(0xf2f2f2)
#define COLOR_BG_BUTTON_Commit UIColorFromRGB(0x36538f)


//*************** 空值判断 *****************
#define DD_StringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )
#define DD_ArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)
#define DD_DictIsEmpty(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys == 0)
#define DD_ObjectIsEmpty(_object) (_object == nil \
|| [_object isKindOfClass:[NSNull class]] \
|| ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
|| ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))


#define DEFINE_SINGLETON_FOR_HEADER(className) \
\
+ (className *)shared##className;

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

#define Font_15 [UIFont systemFontOfSize:15]
#define Font_16 [UIFont systemFontOfSize:16]

/** 屏幕宽高*/
#define kScreenWidth [UIScreen mainScreen].bounds.size.width
#define kScreenHeight [UIScreen mainScreen].bounds.size.height
#define kScale (kScreenWidth /414)

#define kScreenSourchWidth [UIScreen mainScreen].bounds.size.width
#define kScreenSourchHeight [UIScreen mainScreen].bounds.size.height

#define HEIGHT_MENU_VIEW(x,y) ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 ? x : y)

#define kFontSize(size) [UIFont systemFontOfSize:size]

/** 适配*/
#define kiOS_5_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0)
#define kiOS_6_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0)
#define kiOS_7_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
#define kiOS_8_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#define kiOS_9_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0)

#define kiPhone4_OR_4s    (kScreenHeight == 480)
#define kiPhone5_OR_5c_OR_5s   (kScreenHeight == 568)
#define kiPhone6_OR_6s   (kScreenHeight == 667)
#define kiPhone6Plus_OR_6sPlus   (kScreenHeight == 736)
#define kiPad (UI_USER_INTEkACE_IDIOM() == UIUserInterfaceIdiomPad)

// 打印日志
#if DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"\n>>>>>>%s [Line:%d] \n%s\n", __FUNCTION__, __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(FORMAT, ...) nil
#endif

#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
//#define DLog(...)
#endif

#endif /* Macros_h */
